package com.codrim.cs.data.server.dao.entity;

import com.codrim.cs.data.rpc.dto.param.StatisticDataDTO;
import com.codrim.cs.data.rpc.dto.result.WholeDayDataResultDTO;
import com.codrim.cs.data.server.dao.entity.unique.key.StatCsAllUniqueKey;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Liang.Zhuge on 28/07/2017.
 */
@EqualsAndHashCode(callSuper = true)
@Data
public abstract class AbstractStatCsAllDO<Key extends StatCsAllUniqueKey> extends AbstractStatCsEntity<Key> {
    private Integer id;

    private Integer sdate;
    private String symbol;
    private Long click;
    private Long uclick;
    private Long conversion;
    private Float pprice;

    public abstract WholeDayDataResultDTO toWholeDayDataResultDTO();

    @Override
    public void plus(AbstractStatCsEntity source) {
        AbstractStatCsAllDO cSource = (AbstractStatCsAllDO) source;
        this.click = add(this.click, cSource.click);
        this.uclick = add(this.uclick, cSource.uclick);
        this.conversion = add(this.conversion, cSource.conversion);
        this.pprice = add(this.pprice, cSource.pprice);
    }

    @Override
    public void plus(StatisticDataDTO data) {
        this.click = add(this.click, data.getClick());
        this.uclick = add(this.uclick, data.getUclick());
        this.conversion = add(this.conversion, data.getConversion());
        this.pprice = add(this.pprice, data.getPutPrice());
    }

}
